import {
    get,
    post,
    postFormData
} from "~/utils/request";

const instanceClient = {
    get: (url, {params} = {}) => {
        return get(url, params).then(data => data.parameter);
    },
    post: (...args) => {
        return post(...args).then(data => data.parameter);
    },
    postFormData: (...args) => {
        return postFormData(...args).then(data => data.parameter);
    },
};
// import axios from "axios";

/**
 * 获取平台信息接口 上传参数：platformCode（平台代码，从浏览器url地址截取）
 */
export const FetchUnitPlatfrom = ({platformCode}) =>
    instanceClient.get(`/unitPlatform/getUnitPlatformByCode/${platformCode}`);

/**
 * 获取企业尾矿库列表接口 上传参数：unitId（企业id,必填）
 */
export const FetchTailingPondiList = ({id}) =>
    instanceClient.get(`/tailingPond/getTailingPondList?unitId=${id}`);

/**
 * 获取尾矿库基本信息接口 上传参数：id（尾矿库id）
 */
export const FetchTailingPond = ({id}) => instanceClient.get(`/tailingPond/getTailingPond/${id}`);

/**
 * 更新尾矿库信息：id（尾矿库id）
 */
export const UpdateTailingPond3DConfig = ({id, config}) => {
    const formData = new FormData();
    for (const [key, value] of Object.entries({
        id: id,
        config3D: JSON.stringify(config),
    })) {
        formData.append(key, value);
    }
    return instanceClient.postFormData(`/group/tailingPond/updateTailingPond`, formData);
};

/**
 * 根据尾矿id获取点位信息
 */
export const FetchMonitorPointList = ({id}) =>
    instanceClient.get(`/group/monitorPoint/getMonitorPointList?tailingPondId=${id}`);

/**
 * 根据点位id获取预警信息
 */
export const FetchWarningManageById = ({id}) =>
    instanceClient.get(`/warningManage/getWarnById/${id}`);

/**
 * 根据尾矿库id查询调洪演算数据
 */
export const FetchCalculusInfoById = ({id}) =>
    instanceClient.get(`/group/floodRouting/getFloodRoutingData/${id}`);

/**
 * 根据尾矿库id获取天气
 */
export const FetchWeatherById = ({id}) =>
    instanceClient.get(`/weatherForecast/getWeatherForecast/${id}`);

/**
 * ================---------------- 鹿見 ----------------================
 */

/**
 * 尾矿库总数和预警数
 */
export const FetchGetTailingAndWarningCount = () =>
    instanceClient.get("/group/indexData/getTailingAndWarningCount");

/**
 * 尾矿库等级
 */
export const FetchGetTailingPondLevel = () =>
    instanceClient.get("/group/indexData/getTailingPondLevel");

/**
 * 运行状况
 */
export const FetchGetTailingRuningStatus = () =>
    instanceClient.get("/group/indexData/getTailingRuningStatus");

/**
 * 尾矿库风险比例
 */
export const FetchGetTailingRiskRatio = () =>
    instanceClient.get("/group/indexData/getTailingRiskRatio");

/**
 * 头顶库地区分布
 */
export const FetchGetTailingHeadLibrary = () =>
    instanceClient.get("/group/indexData/getTailingHeadLibrary");

/**
 * 降雨量
 */
export const FetchGetTailingRain = () => instanceClient.get("/group/indexData/getTailingRain");

/**
 * 传感器设备统计
 */
export const FetchGetTailingSensorStatistics = () =>
    instanceClient.get("/group/indexData/getTailingSensorStatistics");

/**
 * 尾矿库地区分布
 */
export const FetchGetTailingLocalDistribution = () =>
    instanceClient.get("/group/indexData/getTailingLocalDistribution");

/**
 * 尾矿库地理位置
 */
export const FetchGetTailingLocation = () =>
    instanceClient.get("/group/indexData/getTailingLocation");

/**
 * 获取rtsp
 */
export const FetchRealRtsp = ({cameraIndexCode}) =>
    instanceClient.get("/group/hikvision/getRealRtspList", {params: {cameraIndexCode}});

/**
 * ================---------------- LJ ---------------================
 */
/**
 * 获取位移过程
 */
export const FetchGetDisplacementProcessByMonitorTypeAll = ({monitorCode, monitorTypeId}) =>
    instanceClient.get("/monitorData/getDisplacementProcessByMonitorTypeAll", {
        params: {monitorCode, monitorTypeId},
    });

/**
 * 获取累计变形
 */
export const FetchGetBdDataOne = ({monitorCode, timeType, startTime, endTime}) =>
    instanceClient.get("/bdData/getBdDataOne", {
        params: {monitorCode, timeType, startTime, endTime},
    });

/**
 * 获取预警查看 http://10.200.1.3/makeng/login?to=%2Fmakeng%2Fwarning-management%2Fdata-warning%2Fsurface-displacement-dw
 */

/**
 * 根据MonitorCode获取类型最新的一条数据
 */
export const getLatestDataByMonitorCode = ({monitorCode}) =>
    instanceClient.get(`/group/monitorData/getLatestDataByMonitorCode/${monitorCode}`);

/**
 * 海康威视摄像头 球机
 */
export const FetchGetClouldControlWithFixed = ({cameraIndexCode, command}) =>
    instanceClient.get(`/hikvision/getClouldControlWithFixed`, {
        params: {cameraIndexCode, command},
    });

/**
 * 海康威视摄像头 球机speed
 */
export const FetchGetClouldControlNoFixed = ({cameraIndexCode, action, command, speed}) =>
    instanceClient.get(`/hikvision/getClouldControlNoFixed`, {
        params: {cameraIndexCode, action, command, speed},
    });

/**
 * 获取表面位移 测点数据
 */
export const getLatestBdData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestBdData`,{params});

/**
 * 获取干滩 测点数据
 */
export const getLatestBeachData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestBeachData`,{params});

/**
 * 获取内部位移 测点数据
 */
export const getLatestInmvData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestInmvData`,{params});

/**
 * 获取水位 测点数据
 */
export const getLatestLevelData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestLevelData`,{params});

/**
 * 获取侵润线 测点数据
 */
export const getLatestPhrlData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestPhrlData`,{params});

/**
 * 获取雨量 测点数据
 */
export const getLatestRainData = (params) =>
    instanceClient.get(`/group/dataVisualization/getLatestRainData`,{params});
